<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>广东省传播平台-预算导入页</title>
		<link rel="stylesheet" type="text/css" href="<%=path%>/css/common.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/css/tag.css" />
		<script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.js"></script>
		<script type="text/javascript"
			src="<%=path%>/js/My97DatePicker/WdatePicker.js"></script>
		<link type="text/css"
			href="<%=path%>/js/jquery-ui-1.8.21.custom/css/smoothness/jquery-ui-1.8.21.custom.css"
			rel="stylesheet" />
		<script type="text/javascript"
			src="<%=path%>/js/jquery-ui-1.8.21.custom/js/jquery-ui-1.8.21.custom.min.js"></script>
		<style type="text/css">
.add_div {
	padding: 0px 0;
	border: 1px solid #0078b6;
}

.add_div .table_add {
	width: 100%;
}

.add_div .table_add tr {
	height: 40px;
}

.add_div .table_add th {
	padding: 0px 0;
	text-align: right;
	color: #000000;
	font-size: 14px;
}

.add_div .table_add td {
	padding: 0px 0;
}
</style>
		<script type="text/javascript">
	$(document).ready(function(){  
   //禁止退格键 作用于Firefox、Opera    
    document.onkeypress = banBackSpace;  
   //禁止退格键 作用于IE、Chrome   
	  document.onkeydown = banBackSpace;  
	});
	//处理键盘事件 禁止后退键（Backspace）密码或单行、多行文本框除外 
function banBackSpace(e){
	//alert(event.keyCode)
    var ev = e || window.event;//获取event对象   
    var obj = ev.target || ev.srcElement;//获取事件源 
    var t = obj.type || obj.getAttribute('type');//获取事件源类型     
    //获取作为判断条件的事件类型 
    var vReadOnly = obj.readOnly;
    var vDisabled = obj.disabled;
    //处理undefined值情况 
    vReadOnly = (vReadOnly == undefined) ? false : vReadOnly;
    vDisabled = (vDisabled == undefined) ? true : vDisabled;
    //当敲Backspace键时，事件源类型为密码或单行、多行文本的，  
    //并且readOnly属性为true或disabled属性为true的，则退格键失效  
    var flag1 = ev.keyCode == 8 && (t == "password" || t == "text" || t == "textarea") && (vReadOnly == true || vDisabled == true);
    //当敲Backspace键时，事件源类型非密码或单行、多行文本的，则退格键失效    
    var flag2 = ev.keyCode == 8 && t != "password" && t != "text" && t != "textarea";
    //判断    
    if (flag2 || flag1) 
        event.returnValue = false;//这里如果写 return false 无法实现效果 
}
</script>

		<script type="text/javascript">
	$(function(){
		$('#dialog').dialog({
			autoOpen: false,
			width: 400,
			height: 410,
			show: "blind",
			hide:"slide"
			//modal: true, overlay: { opacity: 0.5, background: "black" } ,	
		});
		$('#dialog_link').click(function(){
			$('#dialog').dialog('open');
			return false;
		})
	
		$('#dialog_01').dialog({
			autoOpen: false,
			width: 500,
			height: 510,
			show: "blind",
			hide:"slide",
			//position: [800,220]  //显示位置
			modal: true, overlay: { opacity: 0.5, background: "black" }	
		});
		$('#dialog_01_btn').click(function(){
			$('#dialog_01').dialog('open');
			return false;
		})
	
		var msg ='${uploadErrorMessage}';
		var msg_01 = "${uploadErrorMessage_01}";
		var noError = '${noError}';
		var noError_01 = "${noError_01}";
		if(null !=msg && msg !=''){
			alert("预算(年)导入成功，请查看错误信息！");
			$("#mediaType").val("");
			$("#dialog_01_btn_spanId").show();
		}else if(null!=noError && noError!=''){
			$("#mediaType").val("");
			alert("预算(年)导入成功！");
		}
		
		if(null !=msg_01 && msg_01 !=''){
			alert("预算(月)导入成功，请查看错误信息！");
			$("#mediaType").val("");
			$("#dialog_02_btn_spanId").show();
		}else if(null!=noError_01 && noError_01!=''){
			$("#mediaType").val("");
			alert("预算(月)导入成功！");
		}
	});

</script>
		<script type="text/javascript">
		//获取文件扩展名   
		function getFileExtendName(filePath){  
		   var extendName = '';  
		 if(filePath != null && $.trim(filePath).length > 0){  
		       filePath = $.trim(filePath);  
		       extendName = filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length);  
		    }  
		    return extendName;  
		}  
		  
		//验证文件扩展名   
		function checkFileExtendName(filePath){  
		    var extendName = getFileExtendName(filePath);  
		   //根据需求定制   
		   var accept_extend = new Array("xls","xlsx");  
		 	var flag = false;  
		 	if(extendName != ''){  
		      for(var i=0; i<accept_extend.length; i++){  
		          if(extendName.toLowerCase() == accept_extend[i])  
		              flag = true;  
		       }  
		   }  
		   return flag;  
		} 
		
	//预算(年)导入验证
	function checkFileType_year(){
		if($.trim($("#uploadFile_01").val()) ==""){
			alert('请选择上传预算(年)附件！');
		    return false;
		}else  if(!checkFileExtendName($("#uploadFile_01").val())){
			alert('文件格式错误,请上传xlsx或xls格式的Excel文件！');
		     return false;
		}else{
			//$("#dialog_Upload_01").parent().appendTo("#form1");
			return true;
		}
	}
	
	//预算(月)导入验证
	function checkFileType_month(){
		if($.trim($("#mediaName").val())==""){
			alert("媒体名称不能为空！");
			return false;
		}
		
		if($.trim($("#uploadFile_02").val()) ==""){
			alert('请选择上传预算(月)附件！');
		    return false;
		}else  if(!checkFileExtendName($("#uploadFile_02").val())){
			alert('文件格式错误,请上传xlsx或xls格式的Excel文件！');
		     return false;
		}else{
			return true;
		}
	}
	
function findAllContract(){ 
	 $.getJSON("findAllMediasummByName!findMedia.action",{mediaName:$("#mediaName").val(),city:$('#city').val(),year:$('#year').val()},function(data){
		 $("#xiangmuId").html("");
		 $.each(data,function(i,value){
			    var id=value.mediaID;
			    var name=value.mediaName;
			    var price = value.idPrice;
			    var idName=id+","+name+"*"+price;
				$("#xiangmuId").append($("<option value='" + idName + "'>" + name + "</option>"));
			});
      });
	
}

// 双击
function xiangmuDBlclick(){
	var media = String($("#xiangmuId").val());
	var start = media.indexOf(',');
	var end = media.indexOf('*');
	$("#dialog_link").val(media.substring(start+1,end));
	$("#dialog_id").val(media.substring(0,start));
	$("#dialog_idprice").val(media.substring(end+1));
	$("#dialog").dialog("close");
}

//重置
function mediaNameRes()
{
	$('#mediaName').attr("value",'');
}
//取消
	function doQuXiao(url){
		if(confirm('您确认取消本次操作？')){
			window.location.href=url;
		}
	}
</script>

	</head>

	<body>
		<!-- 顶栏start -->
		<jsp:include page="../common/top.jsp"></jsp:include>
		<!-- 顶部end -->

		<!-- 顶部start -->
		<div id="main">
			<div class="body">
				<jsp:include page="../common/nav.jsp"></jsp:include>
				<!-- 主体 -->
				<div class="main_body">
					<div class="add_div">
						<table width="100%" cellpadding="0" cellspacing="0">
							<tr>
								<td>
									<div class="add_div"
										style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none;">
										<div class="add_div"
											style="border-top-style: none; border-left-style: none; border-right-style: none;">
											<table style="width: 100%;" cellpadding="0" cellspacing="0">
												<tr
													style="height: 30px; font-size: 16px; color: #000000; background: url(<%=path%>/images/banners30.jpg) repeat;">
													<td style="padding-left: 30px;">
														<b>预算(年)导入</b>
													</td>
												</tr>
											</table>
										</div>
										<form action="doUploadSourcePlanByYearAction.action"
											onsubmit="return checkFileType_year();" id="form1"
											method="post" enctype="multipart/form-data">
											<table style="width: 100%;" cellpadding="0" cellspacing="0">
												<tr>
													<td>
														<table cellpadding="5" cellspacing="20" width="100%">
															<tr>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>年份：</b>
																</th>
																<td>
																	<input name="year" type="text" class="text Wdate"
																		onfocus="WdatePicker({dateFmt:'yyyy',minDate:${year}})"
																		style="width: 225px;" value="${year}" />
																	<span style="color: red;">*</span>
																</td>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>地市：</b>
																</th>
																<td>
																	<input type="text" class="text" style="width: 225px;"
																		value="${cityValue}" />
																	<input type="hidden" name="cityKey" class="text"
																		style="width: 225px;" value="${cityKey}" />
																	<span style="color: red;">*</span>
																</td>
															</tr>
															<tr>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>费用类型：</b>
																</th>
																<td>
																	<input type="text" class="text" style="width: 225px;"
																		value="广告费" />
																	<input type="hidden" name="costType"
																		class="text" style="width: 225px;" value="1" />
																	<span style="color: red;">*</span>
																</td>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>费用子类：</b>
																</th>
																<td>
																	<s:select name="costSubtype"
																		list="#{'101':'统购媒体-固定类','102':'统购媒体-非固定类','103':'统购媒体-机动','104':'备选媒体-公关传播'}"
																		listKey="key" listValue="value"
																		cssStyle="width:227px;">
																	</s:select>
																	<span style="color: red;">*</span>
																</td>
															</tr>
															<tr>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>预算(年)导入：</b>
																</th>
																<td colspan="3">
																	<input type="file" id="uploadFile_01" name="uploadFile_01" />
																	<span style="color: red;">*</span>
																</td>
															</tr>
															<tr>
																<td colspan="4" style="text-align: center;">
																	<input type="submit" class="btn-title" value="导入预算(年)" />
																	<span id="dialog_01_btn_spanId" style="display: none;">&nbsp;&nbsp;
																		<input type="button" id="dialog_01_btn"
																			class="btn-title" value="导入预算(年)错误信息" /></span>
																	&nbsp;&nbsp;
																<input type="button" class="btn-title" value="取消" onclick="doQuXiao('budgetList.action');" />
																</td>
															</tr>
														</table>
													</td>
												</tr>
											</table>
											
										</form>
									</div>
								</td>
							</tr>
							
							<tr>
								<td>
									<div class="add_div"
										style="border-left-style: none; border-bottom-style: none; border-right-style: none;">
										<div class="add_div"
											style="border-top-style: none; border-left-style: none; border-right-style: none;">
											<table style="width: 100%;" cellpadding="0" cellspacing="0">
												<tr
													style="height: 30px; font-size: 16px; color: #000000; background: url(<%=path%>/images/banners30.jpg) repeat;">
													<td style="padding-left: 30px;">
														<b>预算(月)导入</b>
													</td>
												</tr>
											</table>
										</div>
										<form action="doUploadSourcePlanByMonthAction.action"
											onsubmit="return checkFileType_month();" id="form2"
											method="post" enctype="multipart/form-data">
											<table style="width: 100%;" cellpadding="0" cellspacing="0">
												<tr>
													<td>
														<table cellpadding="5" cellspacing="20" width="100%">
															<tr>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>年份：</b>
																</th>
																<td>
																	<input id="year" name="year" type="text" class="text Wdate"
																		onfocus="WdatePicker({dateFmt:'yyyy',minDate:${year}})"
																		style="width: 225px;" value="${year}" />
																	<span style="color: red;">*</span>
																</td>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>地市：</b>
																</th>
																<td>
																	<input type="text" class="text" style="width: 225px;"
																		value="${cityValue}" />
																	<input type="hidden" id="city" name="cityKey" class="text"
																		style="width: 225px;" value="${cityKey}" />
																	<span style="color: red;">*</span>
																</td>
															</tr>
															<tr>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>费用类型：</b>
																</th>
																<td>
																	<input type="text" class="text" style="width: 225px;"
																		value="广告费" />
																	<input type="hidden" name="costType"
																		class="text" style="width: 225px;" value="1" />
																	<span style="color: red;">*</span>
																</td>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>费用子类：</b>
																</th>
																<td>
																	<s:select name="costSubtype"
																		list="#{'101':'统购媒体-固定类','102':'统购媒体-非固定类','103':'统购媒体-机动','104':'备选媒体-公关传播'}"
																		listKey="key" listValue="value"
																		cssStyle="width:227px;">
																	</s:select>
																	<span style="color: red;">*</span>
																</td>
															</tr>
															<tr>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>媒体名称：</b>
																</th>
																<td>
																	<input id='dialog_link' name='mediaName'
																		class='text' type='text' style='width: 225px;'
																		readonly='readonly' />
																	<span style="color: red">*</span>
																	<input id='dialog_id' name='mediaID'
																		class='text' type='hidden' style='width: 225px;'
																		readonly='readonly' />
																	<input id='dialog_idprice'
																		name='priceID' class='text'
																		type='hidden' style='width: 225px;'
																		readonly='readonly' />
																</td>
																<th
																	style="font-size: 14px; text-align: right; color: #000000;">
																	<b>预算(月)导入：</b>
																</th>
																<td>
																	<input type="file" id="uploadFile_02" name="uploadFile_02" />
																	<span style="color: red;">*</span>
																</td>
															</tr>
															<tr>
																<td colspan="4" style="text-align: center;">
																	<input type="submit" class="btn-title" value="导入预算(月)" />
																	<span id="dialog_02_btn_spanId" style="display: none;">&nbsp;&nbsp;
																		<input type="button" id="dialog_02_btn"
																			class="btn-title" value="导入预算(月)错误信息" /></span>
																	&nbsp;&nbsp;
																<input type="button" class="btn-title" value="取消" onclick="doQuXiao('budgetList.action');" />
																</td>
															</tr>
														</table>
													</td>
												</tr>
											</table>
											
											<div id="dialog" title="媒体名称" style="display: block;">
												<table width="0" border="0" cellspacing="2" cellpadding="2">
													<tr>
														<td>
															<input id="mediaName" type="text" style="width: 250px"
																class="text" />
															&nbsp;&nbsp;
															<input type="button" class="btn-title" value="查找"
																onclick="findAllContract();" />
															<input type="reset" class="btn-title" value="重置"
																onclick="mediaNameRes();" />
														</td>
													</tr>
													<tr>
														<td>
															<select id="xiangmuId" multiple="multiple"
																style="width: 100%; height: 335px; overflow: hidden"
																ondblclick="xiangmuDBlclick();">
																<s:iterator id="ms" value="mediaSummaries">
																	<option
																		value="${ms.mediaID},${ms.mediaName}*${ms.idPrice}">
																		${ms.mediaName}
																	</option>
																</s:iterator>
															</select>
														</td>
													</tr>
												</table>
											</div>
											
										</form>
									</div>
								</td>
							</tr>
						</table>

						<div id="dialog_01" title="导入后的错误信息" style="display: none;">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td style="color: red;">
										${uploadErrorMessage} ${uploadErrorMessage_01}
									</td>
								</tr>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- 底部start -->
		<div id="bottom">
			<div class="body">
				<label>
					版权所有&nbsp;&nbsp;&nbsp;&nbsp;2012东莞移动
				</label>
			</div>
		</div>
		<!-- 底部end -->
	</body>
</html>
